﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using COM.OA.Entity;
using System.Collections.Generic;
using COM.OA.BLL;

public partial class linminchao_bbs_lt_lookbbs : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        users loginuser = Session["loginuser"] as users;
        if (loginuser == null)
        {
            this.Response.Write(string.Format(GetRedirect.ALLREDIRECT, "../../login.aspx"));
        }
        else
        {
            string page = this.Request["page"];
            string where = "1=1";
            IList<bbs> ilist = bbsBLL.Select(where);
            int count = ilist.Count;
            float countd = count;
            double weiy = Math.Ceiling(countd / 2);
            int weiye = Int32.Parse(weiy.ToString());//总页数
            int pages = 1;
            int shangpage = 1;
            int xiapage = 1;
            IList<bbs> bbsIlist;
            if (page == null)
            {
                bbsIlist = bbsBLL.Select(2, 1, where);
                shangpage = 1;
                xiapage = 2;
            }
            else
            {
                pages = Int32.Parse(page);
                shangpage = pages - 1;
                xiapage = pages + 1;
                bbsIlist = bbsBLL.Select(2, pages, where);
            }
            List<department> deptlist;
            this.Response.Write("<div align='center'><table width='100%' height='1' border='0'' cellpadding='0' cellspacing='0'><tr><td colspan='2'></td></tr><tr><td width='15'>&nbsp;</td><td width='627' height='21' valign='baseline'><div align='right'><form name='form1' method='post' action='' onsubmit='return dis()'><input name='q' type='text' id='q' value=''><input name='submit' type=submit id='submit' style='FONT-SIZE: 12px; HEIGHT: 27px'  value= ' 查 询 ' ></form></div></td><td width='114' valign='baseline'><div align='center'><a href=''></a><img src='../img/txl/touxiangman.gif' width='19' height='21'><a href='lt_touxiang.aspx'>上传头像</a></div></td><td width='84' valign='baseline'><div align='center'><img src='../img/face1.gif' width='16' height='14'>&nbsp;<a href='lt_addlt.aspx'>发表帖子</a></div></td><td width='123' valign='baseline'><div align='center'><a href='lt_addlt.aspx'><img src='../img/new.gif' width='113' height='23' border='0'></a></div></td><td width='9'>&nbsp;</td></tr><tr><td colspan='6'></td></tr></table></div><div align='center'><div class='RoundedCorner'> <b class='rtop'><b class='r1'></b><b class='r2'></b><b class='r3'></b><b class='r4'></b></b> <span class='style1'>内 部 论 坛 列 表</span></div><table width='760' border='0' cellpadding='0' cellspacing='0'></table>");
            this.Response.Write("<table width='100%' border='0' cellpadding='0' cellspacing='0' bgcolor=''><tr><td bgcolor='#FFFFFF'><p></p><table width='100%' border='0' cellpadding='5' cellspacing='1' bgcolor='#5AAE18'><tr bgcolor='#FFFFFF'></tr><tr bgcolor='#FFFFFF'> <td colspan='6'><table width='100%' border='0' cellpadding='3' cellspacing='0'><tr><td>");
            IList<department> depts = departmentBLL.Select();
            deptlist = (List<department>)depts;
            deptlist.Reverse();
            foreach (department dept in deptlist)//部门查询
            {

                this.Response.Write("&nbsp;&nbsp;&nbsp;&nbsp;<a href='lt_allFY.aspx?t=" + dept.dept_id + "'>" + dept.dept_department + "</a>");
            }
            this.Response.Write("&nbsp; &nbsp; </td></tr></table></td></tr>");
            this.Response.Write("<tr bgcolor='#FFFFFF'><td width='20'><img src='../img/folder.gif' width='25' height='23'></td><td width='563'><strong>主 题</strong></td><td width='68'><div align='center'><p><strong>作</strong><strong> 者</strong></p></div></td><td width='48'><div align='center'><strong>回 复</strong></div></td><td width='48'><div align='center'><strong> 查 看</strong></div></td><td width='166'><div align='center'><strong>时　间</strong></div></td></tr>");

            foreach (bbs bb in bbsIlist)
            {
                int u_id = Int32.Parse(bb.bbs_author);
                users uu = usersBLL.Select(u_id);
                this.Response.Write("<tr bgcolor='#FFFFFF' ><td width='20' ><img src='../img/folder.gif' width='25' height='23'></td><td></a><a href='lt_lookOne.aspx?bbs_id=" + bb.bbs_id + "'><font color='blue'>" + bb.bbs_title + "</a></td><td><div align='center'>" + uu.u_username + "</div></td><td><div align='center'>" + bb.bbs_reverts + "</div></td><td><div align='center'>" + bb.bbs_reads + "</div></td><td><div align='center'><font color='#FF0000'>" + bb.bbs_releasetime + "</font></div></td></tr>");
            }
            this.Response.Write("<tr bgcolor='#FFFFFF' ><td></td><td colspan='1' style='width: 175px; height: 21px; text-align: left;' colspan='2'><div  align='center'>");
            if (shangpage == pages || shangpage == 0)
            {
                this.Response.Write("首页");

            }
            else
            {
                this.Response.Write("<a href='lt_lookbbs.aspx?page=" + shangpage + "'>上一页</a>");
            }
            if (pages == weiye || weiye == 0 || weiye == 1)
            {

                this.Response.Write("&nbsp; &nbsp; &nbsp;尾页");
            }
            else
            {

                this.Response.Write("&nbsp; &nbsp; &nbsp; <a href='lt_lookbbs.aspx?page=" + xiapage + "'>下一页</a>");
            }
            this.Response.Write("</div><td></td><td></td><td></td><td></td></tr></table></td></tr></table>");
            int tiao = ilist.Count;
            this.Response.Write("<p>&nbsp; (总共" + tiao + "条帖子)<br><br><span class='style8'><img src='../img/up.gif' width='17' height='12'><a href='javascript:history.go(-1)'>返 回</a></span>  </p><table border='0' width='31%' align='center'><tr><td width='23%' align='center'></td><td width='31%' align='center'></td> <td width='23%' align='center'></td><td width='23%' align='center'></td></tr></table></div>");

        }
    }
}
